Skip to content

Conversation

@LilyFirefly
Copy link
Contributor

Convert fluent errors into annotated source code, using the miette crate.

@LilyFirefly LilyFirefly marked this pull request as ready for review August 4, 2025 08:14
@LilyFirefly LilyFirefly requested a review from a team as a code owner August 4, 2025 08:14
@LilyFirefly LilyFirefly force-pushed the improve-parser-error-reporting branch 3 times, most recently from acf9710 to a65c5a7 Compare August 4, 2025 08:40
@LilyFirefly LilyFirefly self-assigned this Aug 4, 2025
@LilyFirefly LilyFirefly added enhancement New feature or request rust Pull requests that update rust code labels Aug 4, 2025
Copy link
Collaborator

@seddonym seddonym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow what a clever crate!

Left a couple of non-blocking comments, feel free to merge.


message = str(exc_info.value)

# Recombine first line if it was too long
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this because there's a dependency on something like the system line length? I wonder if there's a way to make it deterministic so we don't need to do this. (No big deal though.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, when testing locally, the file_path is an absolute path, which was too long to fit on one line. I would have liked to make it deterministic, but I couldn't think of a clean way to do it. We probably do want absolute paths rather than relative (relative to what?) in real use.

message = "\n".join(lines)
# End recombination

assert message == f"""\
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐼 Sometimes I like to use textutils.dedent so the string can match the indentation level of the test.

Copy link
Contributor Author

@LilyFirefly LilyFirefly Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I considered that, but decided in this case this was good enough.

@seddonym
Copy link
Collaborator

seddonym commented Aug 4, 2025

Oh - might be worth adding a line to the CHANGELOG about this, but no big deal.

This uses the wonderful `miette` crate for annotating the `.flt` file
source code.
@LilyFirefly LilyFirefly force-pushed the improve-parser-error-reporting branch from a65c5a7 to 97e314c Compare August 4, 2025 09:01
@LilyFirefly LilyFirefly merged commit d49426a into kraken-tech:main Aug 4, 2025
1 check passed
@LilyFirefly LilyFirefly deleted the improve-parser-error-reporting branch August 4, 2025 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants